package src.tfhka;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.TooManyListenersException;
import javax.comm.CommPortIdentifier;
import javax.comm.PortInUseException;
import javax.comm.SerialPort;
import javax.comm.SerialPortEvent;
import javax.comm.SerialPortEventListener;
import javax.comm.UnsupportedCommOperationException;

public class Tfhka  implements SerialPortEventListener {
	
	private static Enumeration listaPuertos;
	private static CommPortIdentifier idPuerto;
	private String status;
	private String error;
	private String datatrama;
	private String descripStatus;
	private String descripError;
	private String[] dataLectorFisc = new String[2000];
	public String Terminar;
	public String Estado;
	private static SerialPort puertoSerie;
	private static OutputStream salida;
	private static InputStream entrada;
	private static final int SCALE_READY = 0;
	private static final int SCALE_READING = 1;
	public boolean IndPuerto = false;
	private static boolean huboSenCmd = false; private static boolean isReport = false; private static boolean is_Z = false;
	private boolean CTS = false; private boolean Bandera = true; private boolean ErroValid = false;
	private static char STX = ' '; private static char ETX = ' '; private static char LRC = ' ';
	private ArrayList listaBytes;
	private int n = 0; private int bytyporleer = 0; private int xor = 0;
	private static int[] recibidosBytes = null;
	private static String statusReceiver = null; private static String errorReceiver = null; private static String lrcReceiver = null; private static String transacctionReceiver = null;
	private static int m_iStatusScale = 0;
	public ReportData ReportePC;
	public ReportData[] ReporteArrayPC;
	public PrinterStatus StatusErrorPrinter;
	public S1PrinterData S1Estado;
	public S2PrinterData S2Estado;
	public S3PrinterData S3Estado;
	public S4PrinterData S4Estado;
	public S5PrinterData S5Estado;
	public S6PrinterData S6Estado;
	public S7PrinterData S7Estado;

	public Tfhka(String puerto)
	{
		OpenFpctrl(puerto);
	}

	public void serialEvent(SerialPortEvent e)
	{
		switch (e.getEventType()) {
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 9:
			case 10:
				break;
			case 1:
				try {
					if (isReport)
						{
						Thread.sleep(50L);
						}
					int b = 0;
					while (entrada.available() > 0) {
							b = entrada.read();
							if ((b == 3) || (b == 23) || (this.xor > 0)) {
								this.xor += 1;
							}
							if (this.n == 0) {
								transacctionReceiver = String.valueOf(b);
							
								if ((b == 6) || (b == 21))
									huboSenCmd = false;
							}
							
							if (this.n == 1)
								statusReceiver = String.valueOf(b);
							
							if (this.n == 2)
								errorReceiver = String.valueOf(b);
							
							if (this.n == 4) {
								lrcReceiver = String.valueOf(b);
							}
							
							Object obj = String.valueOf(b);
							this.listaBytes.add(obj);
							m_iStatusScale = 1;

							this.n += 1;
					}

					if (this.n > 1)
					{
						if ((this.xor == 2) && (this.n >= 4))
						{
							recibidosBytes = new int[this.n];
							int x = 0;
							int q = this.listaBytes.size();
							Object[] lista = this.listaBytes.toArray();
							while (x < q)
							{
								String J = (String)lista[x];
								recibidosBytes[x] = Integer.valueOf(J).intValue();
								x++;
							}
							this.listaBytes = null;
						}

					}

					synchronized (this) {
						m_iStatusScale = 0;
						notifyAll();
					}
				}catch (IOException ioe)
				{
				}catch (NullPointerException npe)
				{
				}catch (NumberFormatException nfe)
				{
				}catch (InterruptedException ie) {
				}
		}	//fin switch (e.getEventType())
  }	//fin serialEvent

	
	private void flush() {
		try {
			salida.flush();
		}catch (IOException e){}
	}

	private void ReiniciarVariables()
	{
		recibidosBytes = null;
		this.n = 0;
		this.xor = 0;
		statusReceiver = null;
		errorReceiver = null;
		lrcReceiver = null;
		transacctionReceiver = null;
	}

	private void readBytes(byte[] palabra) throws IOException {
		synchronized (this)
		{
			salida.write(palabra);
			flush();

			while (m_iStatusScale != 0) {
				try
				{
					wait(10L);
				}catch (InterruptedException e){}
			}

			if (huboSenCmd)
			{
				int q = 0; int limite = 10;
				if (is_Z){
					limite = 20;
					is_Z = false;
				}
				while ((huboSenCmd) && (q < limite)) {
					try {
						wait(1000L);
					} catch (InterruptedException e) {}
					q++;
				}
				huboSenCmd = true;
			}
			else {
				int q = 0; int limite = 5;
				if (is_Z)
				{
					limite = 10;
					is_Z = false;
				}
				while ((recibidosBytes == null) && (q < limite))
				{
					try {
						wait(1000L);
					} catch (InterruptedException e) {}
					q++;
				}
			}
		} //fin synchronized
  }


	public boolean OpenFpctrl(String IpPortName)
	{
		this.Terminar = IpPortName;
		boolean puerto = false;
		try
		{
			listaPuertos = CommPortIdentifier.getPortIdentifiers();
			while (listaPuertos.hasMoreElements()) {
				idPuerto = (CommPortIdentifier)listaPuertos.nextElement();
				if ((idPuerto.getPortType() == 1) && 
						(idPuerto.getName().equals(IpPortName)))
					{
					puertoSerie = (SerialPort)idPuerto.open("AplEscritura", 2000);

					puerto = true;

					salida = puertoSerie.getOutputStream();
					entrada = puertoSerie.getInputStream();
					puerto = puerto;

					puertoSerie.setSerialPortParams(9600, 8, 1, 2);

					puerto = puerto;

					puertoSerie.notifyOnOutputEmpty(true);
					puertoSerie.addEventListener(this);
					puertoSerie.notifyOnDataAvailable(true);
					puertoSerie.notifyOnCTS(true);

					puerto = puerto;
					}

			}	//fin listaPuertos.hasMoreElements()

			if (puerto == true)
				this.Estado = "Puerto Abierto";
			else {
				this.Estado = "Error al Abrir puerto";
			}

			this.IndPuerto = puerto;

			return puerto;
		}catch (TooManyListenersException e){
			this.Estado = e.getMessage();
			return false;
		}catch (PortInUseException e) {
			this.Estado = e.getMessage();
			return false;
		}catch (IOException e) {
			this.Estado = e.getMessage();
			return false;
		}catch (UnsupportedCommOperationException e) {
			this.Estado = e.getMessage();
			return false;
		}catch (Exception ioe) {
			this.Estado = ioe.getMessage();
		}return false;
		
	}		// fin OpenFpctrl

	
	public void CloseFpctrl()
	{
		try
		{
			puertoSerie.close();
			this.IndPuerto = false;
		}catch (NullPointerException e){}
	}

	public boolean CheckFprinter()
	{
		this.listaBytes = new ArrayList();
		try
		{
			ManipulaCTS_RTS();
		}catch (IOException ioe) {
    	this.CTS = false;
    	this.Bandera = false;

    	CloseFpctrl();
    	OpenFpctrl(this.Terminar);
		}

		if (this.CTS == true) {
			int t = 0;
			if (this.IndPuerto == true) {
				try {
					readBytes(new byte[] { 5 });
					t = this.n;
					ReiniciarVariables();
					if (t != 0)
					{
						if (this.Bandera == true)
							puertoSerie.setRTS(false);
						return true;
					}
					if (this.Bandera == true)
						puertoSerie.setRTS(false);
					return false;
				}catch (IOException e4)
				{
					this.Estado = e4.getMessage();
					CloseFpctrl();
					OpenFpctrl(this.Terminar);
					return false;
				}catch (NullPointerException e1) {
					this.Estado = e1.getMessage();
					if ((this.Bandera == true) && (puertoSerie != null))
						puertoSerie.setRTS(false);
					return false;
				}
			}
			
			this.Estado = "Port Closed";
			if ((this.Bandera == true) && (puertoSerie != null))
				puertoSerie.setRTS(false);
			
			return false;
				
		}		//fin this.CTS == true
		
		try {
			this.Estado = "Error... CTS in false";
			if ((this.Bandera == true) && (puertoSerie != null))
				puertoSerie.setRTS(false);
			
			return false;
		} catch (IllegalStateException e11) {
			this.Estado = ("Error... " + e11.getMessage());
		}
		
		return false;
	}	// fin CheckFprinter

	public boolean SendCmd(String cmd) throws PrinterExeption {
		this.listaBytes = new ArrayList();
		huboSenCmd = true;
		if (cmd.equals("I0Z"))
			is_Z = true;
		try
		{
			ManipulaCTS_RTS();
		}catch (IOException ioe) {
			this.CTS = false;
			this.Bandera = false;
			CloseFpctrl();
			OpenFpctrl(this.Terminar);
		}

		if (this.CTS == true) {
			STX = '\002';
			ETX = '\003';
			Do_XOR(cmd);

			byte[] vectorbyte = new byte[cmd.length() + 3];
			vectorbyte[0] = ((byte)STX);
			int x = 0;
			char[] arraychar = cmd.toCharArray();
			while (x < cmd.length())
			{
				vectorbyte[(x + 1)] = ((byte)arraychar[x]);
				x++;
			}
			
			vectorbyte[(x + 1)] = ((byte)ETX);
			vectorbyte[(x + 2)] = ((byte)LRC);
			
			try {
				readBytes(vectorbyte);

				int t = Integer.valueOf(transacctionReceiver).intValue();
				ReiniciarVariables();
				if (t == 6) {
					if (this.Bandera == true) {
						puertoSerie.setRTS(false);
					}
					
					DarStatus_Error(0, 64);
					this.StatusErrorPrinter = new PrinterStatus(Integer.parseInt(this.status), Integer.parseInt(this.error), this.ErroValid, this.descripStatus, this.descripError);

					return true;
				}
				
				getPrinterStatus();
				this.Estado = (" Status: " + this.StatusErrorPrinter.getPrinterStatusCode() + "  Error: " + this.StatusErrorPrinter.getPrinterErrorCode());

				if (this.Bandera == true) {
					puertoSerie.setRTS(false);
				}
				return false;
			}catch (IOException e){
					this.Estado = ("Error... " + e.getMessage());

					DarStatus_Error(0, 128);
					this.StatusErrorPrinter = new PrinterStatus(Integer.parseInt(this.status), Integer.parseInt(this.error), this.ErroValid, this.descripStatus, this.descripError);

					CloseFpctrl();
					OpenFpctrl(this.Terminar);

					throw new PrinterExeption(this.Estado, this.StatusErrorPrinter);
			}catch (NullPointerException e1) {
					getPrinterStatus();
					this.Estado = ("Error... " + e1.getMessage());

					if ((this.Bandera == true) && (puertoSerie != null))
						puertoSerie.setRTS(false);
					throw new PrinterExeption(this.Estado, this.StatusErrorPrinter);
			}catch (Exception e8) {
					getPrinterStatus();
					this.Estado = ("Error... " + e8.getMessage());

					if ((this.Bandera == true) && (puertoSerie != null))
						puertoSerie.setRTS(false);
					throw new PrinterExeption(this.Estado, this.StatusErrorPrinter);
			}
		}	//fin this.CTS == true
		
		try{
			getPrinterStatus();
			this.Estado = "Error... CTS in false";

			if ((this.Bandera == true) && (puertoSerie != null))
				puertoSerie.setRTS(false);
			throw new PrinterExeption(this.Estado, this.StatusErrorPrinter);
		} catch (IllegalStateException e11) {
			getPrinterStatus();
			this.Estado = ("Error... " + e11.getMessage());
		}
		throw new PrinterExeption(this.Estado, this.StatusErrorPrinter);
	}	//fin SendCmd

	
	private int SendCmd_Archivos(String cmd) throws InterruptedException {
		this.listaBytes = new ArrayList();
		STX = '\002';
		ETX = '\003';
		Do_XOR(cmd);

		byte[] vectorbyte = new byte[cmd.length() + 3];
		vectorbyte[0] = ((byte)STX);
		int x = 0;
		char[] arraychar = cmd.toCharArray();
		while (x < cmd.length())
		{
			vectorbyte[(x + 1)] = ((byte)arraychar[x]);
			x++;
		}
	
		vectorbyte[(x + 1)] = ((byte)ETX);
		vectorbyte[(x + 2)] = ((byte)LRC);
		
		try	{
			readBytes(vectorbyte);

			return this.n;
		} catch (IOException e) {
			this.Estado = ("Error... " + e.getMessage());
			return 0;
		} catch (NullPointerException e1) {
			this.Estado = ("Error... " + e1.getMessage());
		}
		
		return 0;
	} 	//fin SendCmd_Archivos

	private void Wait_CTS()
	{
		long time = 0L; long time2 = 0L; long diff = 0L;
		Calendar calendario = new GregorianCalendar();
		time = calendario.getTimeInMillis();
		do {
			Calendar calendario2 = new GregorianCalendar();
			time2 = calendario2.getTimeInMillis();

			diff = time2 - time;
			this.CTS = puertoSerie.isCTS();
		}while ((!this.CTS) && (diff < 100000000L));
	}

	public int SendFileCmd(String file)
	{
		try{
			ManipulaCTS_RTS();
		} catch (IOException ioe) {
			this.CTS = false;
			this.Bandera = false;

			CloseFpctrl();
			OpenFpctrl(this.Terminar);
		}
	
		if (this.CTS == true)
			try {
				FileReader fr = new FileReader(file);
				BufferedReader entradaf = new BufferedReader(fr);

				int ite = 0;
				String s;
				while ((s = entradaf.readLine()) != null) {
					boolean rep = SendCmd(s);
					ite++;
				}
				
				entradaf.close();
				if ((this.Bandera == true) && (puertoSerie != null))
					puertoSerie.setRTS(false);
		
				return ite;
			} catch (FileNotFoundException fnfex) {
				if ((this.Bandera == true) && (puertoSerie != null))
					puertoSerie.setRTS(false);
				
				this.Estado = fnfex.getMessage();
				return -1;
			} catch (IOException ioex) {
				CloseFpctrl();
				OpenFpctrl(this.Terminar);
				this.Estado = ioex.getMessage();
				return 0;
			} catch (PrinterExeption pex) {
				this.Estado = pex.getMessage();
				return 0;
			}
    
			try {
				this.Estado = "Error... CTS in false";
				if ((this.Bandera == true) && (puertoSerie != null))
					puertoSerie.setRTS(false);
				
				return 0;
			} catch (IllegalStateException e11) {
				this.Estado = ("Error... " + e11.getMessage());
			}
			return 0;
	}

	public boolean UploadStatusCmd(String Cmd, String file)	{
		try {
			ManipulaCTS_RTS();
		} catch (IOException ioe) {
			this.CTS = false;
			this.Bandera = false;

			CloseFpctrl();
			OpenFpctrl(this.Terminar);
		}
		
		if (this.CTS == true) {
			String lineno = "";
			int interv = 0;
			
			try {
				FileWriter fw = new FileWriter(file);
				BufferedWriter bw = new BufferedWriter(fw);
				PrintWriter salidaf = new PrintWriter(bw);

				interv = SubirDataPCStatus(Cmd);

				int x = 0;
				while (x < interv)
				{
					lineno = lineno + this.dataLectorFisc[x] + "\r\n";
					x++;
				}

				salidaf.println(lineno);
				salidaf.close();
				if ((this.Bandera == true) && (puertoSerie != null)) {
					puertoSerie.setRTS(false);
				}
				if (interv != 0)
				{
					this.Estado = " Status: 00  Error: 00";
					return true;
				}

				this.Estado = "Sin repuesta";
				return false;
			} catch (IOException ioex) {
				this.Estado = ioex.getMessage();
				CloseFpctrl();
				OpenFpctrl(this.Terminar);
				return false;
			} catch (NullPointerException e2) {
				this.Estado = e2.getMessage();
				if ((this.Bandera == true) && (puertoSerie != null))
					puertoSerie.setRTS(false);
				return false;
			} catch (InterruptedException e3) {
				this.Estado = e3.getMessage();
				if ((this.Bandera == true) && (puertoSerie != null))
					puertoSerie.setRTS(false);

				return false;
			}
		}
		
		try {
			this.Estado = "Error... CTS in false";
			if ((this.Bandera == true) && (puertoSerie != null))
				puertoSerie.setRTS(false);
			return false;
		} catch (IllegalStateException e11) {
			this.Estado = ("Error... " + e11.getMessage());
		}
		
		return false;
	}	// fin UploadStatusCmd

	public boolean UploadReportCmd(String Cmd, String file)	{
	    try {
	    	ManipulaCTS_RTS();
	    } catch (IOException ioe) {
	    	this.CTS = false;
	    	this.Bandera = false;
	
	    	CloseFpctrl();
	    	OpenFpctrl(this.Terminar);
	    }
	    
	    if (this.CTS == true) {
	    	String lineno = "";
	    	int interv = 0;
	    	
	    	try {
	    		FileWriter fw = new FileWriter(file);
	    		BufferedWriter bw = new BufferedWriter(fw);
	    		PrintWriter salidaf = new PrintWriter(bw);

	    		if (Cmd.length() == 3)
	    			interv = SubirDataPC(Cmd);
	    		else {
	    			interv = SubirDataPC2(Cmd);
	    		}
	    		
	    		int x = 0;
	    		while (x < interv) {
	    			lineno = lineno + this.dataLectorFisc[x] + "\r\n";
	    			x++;
	    		}

	    		salidaf.println(lineno);
	    		salidaf.close();
	    		
	    		if ((this.Bandera == true) && (puertoSerie != null)) {
	    			puertoSerie.setRTS(false);
	    		}

	    		if (interv != 0) {
	    			this.Estado = " Status: 00  Error: 00";
	    			return true;
	    		}

	    		this.Estado = "Sin repuesta";
	    		return false;
	    	} catch (IOException ioex) {
	    		this.Estado = ioex.getMessage();
	    		CloseFpctrl();
	    		OpenFpctrl(this.Terminar);
	    		return false;
	    	} catch (NullPointerException e2) {
	    		this.Estado = e2.getMessage();
	    		if ((this.Bandera == true) && (puertoSerie != null))
	    			puertoSerie.setRTS(false);
	    		
	    		return false;
	    	} catch (InterruptedException e3) {
	    		this.Estado = e3.getMessage();
	    		if ((this.Bandera == true) && (puertoSerie != null))
	    			puertoSerie.setRTS(false);
	    		return false;
	    	}
	    }
	    try {
	    	this.Estado = "Error... CTS in false";
	    	if ((this.Bandera == true) && (puertoSerie != null))
	    		puertoSerie.setRTS(false);

	    	return false;
	    } catch (IllegalStateException e11) {
	    	this.Estado = ("Error... " + e11.getMessage());
	    }
	    
	    return false;
	} // fin UploadReportCmd

	
	private int SubirDataPC(String Cmd) throws IOException, InterruptedException, NullPointerException
	{
		isReport = true;
		this.dataLectorFisc = new String[2000];
		int t = 0; int interv = 0;

		huboSenCmd = true;
		SendCmd_Archivos(Cmd);
		this.bytyporleer = this.n;
		if (isReport) {
			int q2 = 0;
			while (this.bytyporleer == 0) {
				this.bytyporleer = this.n;
				Thread.sleep(100L);
				q2++;

				if ((q2 == 100) && (this.bytyporleer == 0)) {
					this.bytyporleer = -1;
				}
			}
		}

		if (this.bytyporleer > 0) {
			huboSenCmd = false;

			ReiniciarVariables();
			this.listaBytes = new ArrayList();

			readBytes(new byte[] { 6 });

			Thread.sleep(500L);

			long w = 0L;

			while ((recibidosBytes == null) && (w < 2000000000L)) {
				w += 1L;
			}

			this.bytyporleer = this.n;
			isReport = false;
			while (this.bytyporleer > 1) {
				t = this.n;
				int ascii = 0;
				char caracter = ' ';
				String trama = "";
				int etx = t - 2;
				int lrc = t - 1;
				t -= 1;

				int n1 = 0;
				while (n1 < t) {
					ascii = recibidosBytes[n1];
					if ((n1 == 0) || (n1 == etx) || (n1 == lrc)) {
						trama = trama + "";
					} else {
						caracter = (char)ascii;
						trama = trama + caracter;
					}

					n1++;
				}

				trama = trama.replaceAll("\n", "");

				this.datatrama = trama;
				this.dataLectorFisc[interv] = trama.replaceAll("\n", "");

				this.bytyporleer = 0;

				ReiniciarVariables();
				this.listaBytes = new ArrayList();

				this.bytyporleer = this.n;

				interv++;
			} // fin while (this.bytyporleer > 1)

		} // fin if (this.bytyporleer > 0)

		return interv;
	}

	private int SubirDataPC2(String Cmd) throws IOException, InterruptedException, NullPointerException {
		isReport = true;
		this.dataLectorFisc = new String[2000];
		int t = 0; int interv = 0;

		huboSenCmd = true;
		SendCmd_Archivos(Cmd);
		this.bytyporleer = this.n;
		int q2 = 0;
		while (this.bytyporleer == 0) {
			this.bytyporleer = this.n;
			Thread.sleep(100L);
			q2++;

			if ((q2 == 100) && (this.bytyporleer == 0)) {
				this.bytyporleer = -1;
			}
		}
		
		if (this.bytyporleer > 0) {
			huboSenCmd = false;

			ReiniciarVariables();
			this.listaBytes = new ArrayList();
			isReport = true;
			readBytes(new byte[] { 6 });

			Thread.sleep(500L);

			long w = 0L;
			while ((recibidosBytes == null) && (w < 2000000000L)){
				w += 1L;
			}

			this.bytyporleer = this.n;

			while (this.bytyporleer > 1)
			{
				t = this.n;
				int ascii = 0;
				char caracter = ' ';
				String trama = "";
				int etx = t - 2;
				int lrc = t - 1;
				t -= 1;

				int n1 = 0;
				while (n1 < t) {
					ascii = recibidosBytes[n1];
					if ((n1 == 0) || (n1 == etx) || (n1 == lrc)) {
						trama = trama + "";
					} else {
						caracter = (char)ascii;
						trama = trama + caracter;
					}

					n1++;
				}

				trama = trama.replaceAll("\n", "");

				this.datatrama = trama;
				this.dataLectorFisc[interv] = trama.replaceAll("\n", "");
				byte bitParada = (byte)recibidosBytes[(this.bytyporleer - 2)];
				this.bytyporleer = 0;

				ReiniciarVariables();
				this.listaBytes = new ArrayList();

				if ((bitParada == 23) || (bitParada == 3))
					readBytes(new byte[] { 6 });
				
				Thread.sleep(50L);

				if (recibidosBytes == null) {
					Thread.sleep(10000L);
				}

				this.bytyporleer = this.n;

				interv++;
			}//	fin while (this.bytyporleer > 1)

		}	//fin if (this.bytyporleer > 0)

		return interv;
	}

	private int SubirDataPCStatus(String Cmd) throws IOException, InterruptedException, NullPointerException {
		isReport = true;
		this.dataLectorFisc = new String[2000];
		int t = 0; int interv = 0;

		huboSenCmd = true;
		SendCmd_Archivos(Cmd);

		Thread.sleep(150L);

		long w = 0L;
		while ((recibidosBytes == null) && (w < 2100000000L)) {
			w += 1L;
		}

		this.bytyporleer = this.n;

		if (this.bytyporleer > 0) {
			huboSenCmd = false;

			while (this.bytyporleer > 1) {
				t = this.n;
				int ascii = 0;
				char caracter = ' ';
				String trama = "";
				int etx = t - 2;
				int lrc = t - 1;
				t -= 1;

				int n1 = 0;
				while (n1 < t) {
					ascii = recibidosBytes[n1];
					if ((n1 == 0) || (n1 == etx) || (n1 == lrc)) {
						trama = trama + "";
					} else {
						caracter = (char)ascii;
						trama = trama + caracter;
					}

					n1++;
				}

				trama = trama.replaceAll("\n", "");

				this.datatrama = trama;
				this.dataLectorFisc[interv] = trama.replaceAll("\n", "");

				this.bytyporleer = 0;

				ReiniciarVariables();
				this.listaBytes = new ArrayList();

				this.bytyporleer = this.n;

				interv++;
			}	//fin while (this.bytyporleer > 1)

		}	//fin if (this.bytyporleer > 0)

		return interv;
	
	}	//fin SubirDataPCStatus

  private void ManipulaCTS_RTS()
    throws IOException
  {
/* 1090 */     this.bytyporleer = 0;
/* 1091 */     if (!this.Bandera)
/* 1092 */       this.Bandera = true;
    try
    {
/* 1095 */       if (puertoSerie.isRTS() == true) {
/* 1096 */         this.CTS = true;
/* 1097 */         this.Bandera = false;
      } else {
/* 1099 */         puertoSerie.setRTS(true);
/* 1100 */         Wait_CTS();
      }
    }
    catch (NullPointerException e5)
    {
/* 1105 */       this.Estado = ("Error... " + e5.getMessage());
/* 1106 */       if ((this.Bandera == true) && (puertoSerie != null))
/* 1107 */         puertoSerie.setRTS(false);
    } catch (IllegalStateException e11) {
/* 1109 */       this.Estado = ("Error... " + e11.getMessage());
    }
  }

  private void Do_XOR(String cmd)
  {
/* 1119 */     String A = ""; String B = "";
/* 1120 */     int N1 = 0; int RX = 0; int IND = 0;
/* 1121 */     char[] vector = cmd.toCharArray();
/* 1122 */     for (int i = 0; i < vector.length; i++)
    {
/* 1124 */       int p = vector[i];
/* 1125 */       A = String.valueOf(p);
/* 1126 */       N1 = p;

/* 1128 */       if (B != "")
/* 1129 */         RX ^= N1;
      else {
/* 1131 */         RX = N1;
      }
/* 1133 */       B = A;

/* 1135 */       IND++;
    }

/* 1138 */     int ival = RX ^ 0x3;
/* 1139 */     LRC = (char)ival;
  }

  private String DarStatus_Error(int st, int er)
  {
/* 1150 */     int st_aux = st;

/* 1152 */     st &= -5;

/* 1155 */     if ((st & 0x6A) == 106)
    {
/* 1157 */       this.status = "12";
/* 1158 */       this.descripStatus = "In Fiscal Mode, Memory Full, in Non Fiscal Transaction";
    }
/* 1160 */     else if ((st & 0x69) == 105)
    {
/* 1163 */       this.status = "11";
/* 1164 */       this.descripStatus = "In Fiscal Mode, Memory Full, in Fiscal Transaction";
    }
/* 1166 */     else if ((st & 0x68) == 104)
    {
/* 1169 */       this.status = "10";
/* 1170 */       this.descripStatus = "In Fiscal Mode Memory Full and Wait";
    }
/* 1172 */     else if ((st & 0x72) == 114)
    {
/* 1176 */       this.status = "09";
/* 1177 */       this.descripStatus = "In Fiscal Mode, Fiscal Memory Near Full, in Non Fiscal Transaction";
    }
/* 1179 */     else if ((st & 0x71) == 113)
    {
/* 1183 */       this.status = "08";
/* 1184 */       this.descripStatus = "In Fiscal Mode, Fiscal Memory Near Full, in Fiscal Transaction";
    }
/* 1186 */     else if ((st & 0x70) == 112)
    {
/* 1189 */       this.status = "07";
/* 1190 */       this.descripStatus = "In Fiscal Mode, Fiscal Memory Near Full and Wait";
    }
/* 1192 */     else if ((st & 0x62) == 98)
    {
/* 1194 */       this.status = "06";
/* 1195 */       this.descripStatus = "In Fiscal Mode, in Non Fiscal Transaction";
    }
/* 1197 */     else if ((st & 0x61) == 97)
    {
/* 1199 */       this.status = "05";
/* 1200 */       this.descripStatus = "In Fiscal Mode, in Fiscal Transaction";
    }
/* 1202 */     else if ((st & 0x60) == 96)
    {
/* 1204 */       this.status = "04";
/* 1205 */       this.descripStatus = "In Fiscal Mode and Wait";
    }
/* 1207 */     else if ((st & 0x42) == 66)
    {
/* 1209 */       this.status = "03";
/* 1210 */       this.descripStatus = "In Non Fiscal Mode, in Non Fiscal Transaction";
    }
/* 1212 */     else if ((st & 0x41) == 65)
    {
/* 1214 */       this.status = "02";
/* 1215 */       this.descripStatus = "In Non Fiscal Mode, in Fiscal Transaction";
    }
/* 1217 */     else if ((st & 0x40) == 64)
    {
/* 1219 */       this.status = "01";
/* 1220 */       this.descripStatus = "In Non Fiscal Mode and Wait";
    }
/* 1222 */     else if ((st & 0x0) == 0)
    {
/* 1224 */       this.status = "00";
/* 1225 */       this.descripStatus = "Unknowed Status";
    }

/* 1231 */     if ((er & 0x6C) == 108)
    {
/* 1233 */       this.error = "108";
/* 1234 */       this.descripError = "Fiscal Memory Full";
/* 1235 */       this.ErroValid = false;
    }
/* 1237 */     else if ((er & 0x64) == 100)
    {
/* 1239 */       this.error = "100";
/* 1240 */       this.descripError = "Memory Fiscal Error";
/* 1241 */       this.ErroValid = false;
    }
/* 1243 */     else if ((er & 0x60) == 96)
    {
/* 1245 */       this.error = "96";
/* 1246 */       this.descripError = "Fiscal Error";
/* 1247 */       this.ErroValid = false;
    }
/* 1249 */     else if ((er & 0x5C) == 92)
    {
/* 1251 */       this.error = "92";
/* 1252 */       this.descripError = "Invalid Commando";
/* 1253 */       this.ErroValid = false;
    }
/* 1255 */     else if ((er & 0x58) == 88)
    {
/* 1257 */       this.error = "88";
/* 1258 */       this.descripError = "No Directives Assigned";
/* 1259 */       this.ErroValid = false;
    }
/* 1261 */     else if ((er & 0x54) == 84)
    {
/* 1263 */       this.error = "84";
/* 1264 */       this.descripError = "Invalid Tax";
/* 1265 */       this.ErroValid = false;
    }
/* 1267 */     else if ((er & 0x50) == 80)
    {
/* 1269 */       this.error = "80";
/* 1270 */       this.descripError = "Command Invalid / Invalid Value";
/* 1271 */       this.ErroValid = false;
    }
/* 1273 */     else if ((er & 0x43) == 67)
    {
/* 1275 */       this.error = "03";
/* 1276 */       this.descripError = "Ends of Paper and Mechanic Error";
/* 1277 */       this.ErroValid = true;
    }
/* 1279 */     else if ((er & 0x42) == 66)
    {
/* 1281 */       this.error = "02";
/* 1282 */       this.descripError = "Mechanic Error with Paper";
/* 1283 */       this.ErroValid = true;
    }
/* 1285 */     else if ((er & 0x41) == 65)
    {
/* 1287 */       this.error = "01";
/* 1288 */       this.descripError = "End of Paper";
/* 1289 */       this.ErroValid = true;
    }
/* 1291 */     else if ((er & 0x40) == 64)
    {
/* 1293 */       this.error = "00";
/* 1294 */       this.descripError = "No Error";
/* 1295 */       this.ErroValid = true;
    }

/* 1299 */     if ((st_aux & 0x4) == 4)
    {
/* 1301 */       this.error = "112";
/* 1302 */       this.descripError = "Buffer Full";
/* 1303 */       this.ErroValid = false;
    }
/* 1305 */     else if (er == 128)
    {
/* 1307 */       this.error = "128";
/* 1308 */       this.descripError = "Communication Error";
/* 1309 */       this.ErroValid = false;
    }
/* 1311 */     else if (er == 137)
    {
/* 1313 */       this.error = "137";
/* 1314 */       this.descripError = "No Answer";
/* 1315 */       this.ErroValid = false;
    }
/* 1317 */     else if (er == 144)
    {
/* 1319 */       this.error = "144";
/* 1320 */       this.descripError = "LRC Error";
/* 1321 */       this.ErroValid = false;
    }
/* 1323 */     else if (er == 145)
    {
/* 1325 */       this.error = "145";
/* 1326 */       this.descripError = "Intern API Error";
/* 1327 */       this.ErroValid = false;
    }
/* 1329 */     else if (er == 153)
    {
/* 1331 */       this.error = "153";
/* 1332 */       this.descripError = "Opening File Error";
/* 1333 */       this.ErroValid = false;
    }
/* 1335 */     else if (er == 71)
    {
/* 1337 */       this.error = "71";
/* 1338 */       this.descripError = "No roll paper bill";
/* 1339 */       this.ErroValid = false;
    }

/* 1342 */     this.Estado = ("Status: " + this.status + "  " + "Error: " + this.error);

/* 1344 */     return this.Estado;
  }

  public boolean ReadFpStatus()
  {
/* 1352 */     this.listaBytes = new ArrayList();
    try
    {
/* 1355 */       ManipulaCTS_RTS();
    }
    catch (IOException ioe) {
/* 1358 */       this.CTS = false;
/* 1359 */       this.Bandera = false;

/* 1361 */       CloseFpctrl();
/* 1362 */       OpenFpctrl(this.Terminar);
    }
/* 1364 */     if (this.CTS == true)
    {
/* 1366 */       int t = 0;
      try
      {
/* 1370 */         if (huboSenCmd)
          try
          {
/* 1373 */             Thread.sleep(2000L);
/* 1374 */             huboSenCmd = false;
          }
          catch (InterruptedException e) {
          }
/* 1378 */         readBytes(new byte[] { 5 });

/* 1380 */         t = this.n;

/* 1382 */         if (t != 0) {
/* 1383 */           int st = 0; int er = 0; int lrc = 0;
/* 1384 */           st = Integer.valueOf(statusReceiver).intValue();
/* 1385 */           er = Integer.valueOf(errorReceiver).intValue();
/* 1386 */           lrc = Integer.valueOf(lrcReceiver).intValue();
/* 1387 */           ReiniciarVariables();

/* 1391 */           DarStatus_Error(st, er);

/* 1394 */           if ((this.status != null) && (this.error != null)) {
/* 1395 */             if (this.Bandera == true) {
/* 1396 */               puertoSerie.setRTS(false);
            }
/* 1398 */             return true;
          }
/* 1400 */           this.Estado = "No hay Repuesta";
/* 1401 */           this.ErroValid = false;
/* 1402 */           this.descripStatus = "No Answer";
/* 1403 */           this.descripError = "No Answer";
/* 1404 */           if (this.Bandera == true)
/* 1405 */             puertoSerie.setRTS(false);
/* 1406 */           return false;
        }

/* 1410 */         DarStatus_Error(0, 137);
/* 1411 */         if (this.Bandera == true)
/* 1412 */           puertoSerie.setRTS(false);
/* 1413 */         return false;
      }
      catch (IOException e) {
/* 1416 */         this.Estado = ("Error... " + e.getMessage());
/* 1417 */         CloseFpctrl();
/* 1418 */         OpenFpctrl(this.Terminar);
/* 1419 */         return false;
      } catch (NullPointerException e1) {
/* 1421 */         this.Estado = ("Error... " + e1.getMessage());
/* 1422 */         if ((this.Bandera == true) && (puertoSerie != null))
/* 1423 */           puertoSerie.setRTS(false);
/* 1424 */         return false;
      }
      catch (NumberFormatException ne) {
/* 1427 */         this.Estado = ("Error... " + ne.getMessage());
/* 1428 */         if ((this.Bandera == true) && (puertoSerie != null))
/* 1429 */           puertoSerie.setRTS(false);
/* 1430 */         return false;
      }
    }
    try {
/* 1434 */       this.Estado = "Error... CTS in false";
/* 1435 */       if ((this.Bandera == true) && (puertoSerie != null))
/* 1436 */         puertoSerie.setRTS(false);
/* 1437 */       return false;
    } catch (IllegalStateException e11) {
/* 1439 */       this.Estado = ("Error... " + e11.getMessage());
/* 1440 */     }return false;
  }

  public PrinterStatus getPrinterStatus()
  {
/* 1450 */     ReadFpStatus();

/* 1452 */     if ((this.status == null) && (this.error == null)) {
/* 1453 */       DarStatus_Error(0, 128);
    }
/* 1455 */     this.StatusErrorPrinter = new PrinterStatus(Integer.parseInt(this.status), Integer.parseInt(this.error), this.ErroValid, this.descripStatus, this.descripError);

/* 1457 */     return this.StatusErrorPrinter;
  }

  public ReportData getXReport()
    throws PrinterExeption
  {
    try
    {
/* 1467 */       int rep = SubirDataPC("U0X");
/* 1468 */       if (rep > 0) {
/* 1469 */         this.ReportePC = new ReportData(this.datatrama);
/* 1470 */         this.Estado = " Status: 00  Error: 00";
      } else {
/* 1472 */         this.ReportePC = null;
/* 1473 */         this.Estado = "Sin repuesta";
/* 1474 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1477 */       return this.ReportePC;
    }
    catch (IOException ex) {
/* 1480 */       this.ReportePC = null;
/* 1481 */       this.Estado = ex.getMessage();
/* 1482 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1484 */       this.Estado = ex.getMessage();
/* 1485 */       this.ReportePC = null;
/* 1486 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1488 */       this.Estado = ex.getMessage();
/* 1489 */       this.ReportePC = null;
/* 1490 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public ReportData getZReport()
    throws PrinterExeption
  {
    try
    {
/* 1502 */       int rep = SubirDataPC("U0Z");
/* 1503 */       if (rep > 0) {
/* 1504 */         this.ReportePC = new ReportData(this.datatrama);
/* 1505 */         this.Estado = " Status: 00  Error: 00";
      } else {
/* 1507 */         this.ReportePC = null;
/* 1508 */         this.Estado = "Sin repuesta";
/* 1509 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1512 */       return this.ReportePC;
    }
    catch (IOException ex) {
/* 1515 */       this.ReportePC = null;
/* 1516 */       this.Estado = ex.getMessage();
/* 1517 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1519 */       this.ReportePC = null;
/* 1520 */       this.Estado = ex.getMessage();
/* 1521 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1523 */       this.ReportePC = null;
/* 1524 */       this.Estado = ex.getMessage();
/* 1525 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public ReportData[] getZReport(int StarReportNumber, int EndReportNumber)
    throws PrinterExeption
  {
/* 1537 */     String IntervaloNi = String.valueOf(StarReportNumber);
/* 1538 */     while (IntervaloNi.length() < 6)
    {
/* 1540 */       IntervaloNi = "0" + IntervaloNi;
    }
/* 1542 */     String IntervaloNf = String.valueOf(EndReportNumber);
/* 1543 */     while (IntervaloNf.length() < 6)
    {
/* 1545 */       IntervaloNf = "0" + IntervaloNf;
    }

    try
    {
/* 1550 */       int rep = SubirDataPC2("U3A" + IntervaloNi + IntervaloNf);

/* 1552 */       if (rep > 0) {
/* 1553 */         int n = 0; int m = 0;
/* 1554 */         while (this.dataLectorFisc[n] != null) {
/* 1555 */           n++;
        }
/* 1557 */         this.ReporteArrayPC = new ReportData[n];
/* 1558 */         while (m < n)
        {
/* 1564 */           this.ReporteArrayPC[m] = new ReportData(this.dataLectorFisc[m]);

/* 1568 */           m++;
        }

/* 1571 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 1575 */         this.ReporteArrayPC = null;
/* 1576 */         this.Estado = "Sin repuesta";

/* 1578 */         if (StarReportNumber > EndReportNumber) {
/* 1579 */           this.Estado = "The original number can not be greater than the final number";
        }
/* 1581 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1584 */       return this.ReporteArrayPC;
    }
    catch (IOException ex) {
/* 1587 */       this.ReporteArrayPC = null;
/* 1588 */       this.Estado = ex.getMessage();
/* 1589 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1591 */       this.ReporteArrayPC = null;
/* 1592 */       this.Estado = ex.getMessage();
/* 1593 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1595 */       this.ReporteArrayPC = null;
/* 1596 */       this.Estado = ex.getMessage();
/* 1597 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public ReportData[] getZReport(Date StarDate, Date EndDate)
    throws PrinterExeption
  {
/* 1609 */     Calendar Cale = Calendar.getInstance();
/* 1610 */     Calendar Cale2 = Calendar.getInstance();
/* 1611 */     Cale.setTime(StarDate);

/* 1613 */     int y = Cale.get(1);
/* 1614 */     int m = Cale.get(2);
/* 1615 */     int d = Cale.get(5);

/* 1617 */     Cale2.setTime(EndDate);

/* 1619 */     int y2 = Cale2.get(1);
/* 1620 */     int m2 = Cale2.get(2);
/* 1621 */     int d2 = Cale2.get(5);

/* 1623 */     String Day = String.valueOf(d);
/* 1624 */     while (Day.length() < 2)
    {
/* 1626 */       Day = "0" + Day;
    }
/* 1628 */     String Mess = String.valueOf(m + 1);
/* 1629 */     while (Mess.length() < 2)
    {
/* 1631 */       Mess = "0" + Mess;
    }
/* 1633 */     String Ano = String.valueOf(y).substring(2, 4);
/* 1634 */     String Day2 = String.valueOf(d2);
/* 1635 */     while (Day2.length() < 2)
    {
/* 1637 */       Day2 = "0" + Day2;
    }
/* 1639 */     String Mess2 = String.valueOf(m2 + 1);
/* 1640 */     while (Mess2.length() < 2)
    {
/* 1642 */       Mess2 = "0" + Mess2;
    }
/* 1644 */     String Ano2 = String.valueOf(y2).substring(2, 4);

/* 1646 */     String IntervaloFi = Day + Mess + Ano;
/* 1647 */     String IntervaloFf = Day2 + Mess2 + Ano2;
    try
    {
/* 1653 */       int rep = SubirDataPC2("U2A" + IntervaloFi + IntervaloFf);

/* 1655 */       if (rep > 0) {
/* 1656 */         int n = 0; int h = 0;
/* 1657 */         while (this.dataLectorFisc[n] != null) {
/* 1658 */           n++;
        }
/* 1660 */         this.ReporteArrayPC = new ReportData[n];
/* 1661 */         while (h < n)
        {
/* 1667 */           this.ReporteArrayPC[h] = new ReportData(this.dataLectorFisc[h]);

/* 1671 */           h++;
        }

/* 1674 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 1678 */         this.ReporteArrayPC = null;
/* 1679 */         this.Estado = "Sin repuesta";

/* 1681 */         if (Integer.parseInt(Ano + Mess + Day) > Integer.parseInt(Ano2 + Mess2 + Day2)) {
/* 1682 */           this.Estado = "The date can not be larger than the final date";
        }
/* 1684 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1687 */       return this.ReporteArrayPC;
    }
    catch (IOException ex) {
/* 1690 */       this.ReporteArrayPC = null;
/* 1691 */       this.Estado = ex.getMessage();
/* 1692 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1694 */       this.ReporteArrayPC = null;
/* 1695 */       this.Estado = ex.getMessage();
/* 1696 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1698 */       this.ReporteArrayPC = null;
/* 1699 */       this.Estado = ex.getMessage();
/* 1700 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public void printZReport(Date StarDate, Date EndDate)
    throws PrinterExeption
  {
/* 1712 */     Calendar Cale = Calendar.getInstance();
/* 1713 */     Calendar Cale2 = Calendar.getInstance();
/* 1714 */     Cale.setTime(StarDate);

/* 1716 */     int y = Cale.get(1);
/* 1717 */     int m = Cale.get(2);
/* 1718 */     int d = Cale.get(5);

/* 1720 */     Cale2.setTime(EndDate);

/* 1722 */     int y2 = Cale2.get(1);
/* 1723 */     int m2 = Cale2.get(2);
/* 1724 */     int d2 = Cale2.get(5);

/* 1726 */     String Day = String.valueOf(d);
/* 1727 */     while (Day.length() < 2)
    {
/* 1729 */       Day = "0" + Day;
    }
/* 1731 */     String Mess = String.valueOf(m + 1);
/* 1732 */     while (Mess.length() < 2)
    {
/* 1734 */       Mess = "0" + Mess;
    }
/* 1736 */     String Ano = String.valueOf(y).substring(2, 4);
/* 1737 */     String Day2 = String.valueOf(d2);
/* 1738 */     while (Day2.length() < 2)
    {
/* 1740 */       Day2 = "0" + Day2;
    }
/* 1742 */     String Mess2 = String.valueOf(m2 + 1);
/* 1743 */     while (Mess2.length() < 2)
    {
/* 1745 */       Mess2 = "0" + Mess2;
    }
/* 1747 */     String Ano2 = String.valueOf(y2).substring(2, 4);

/* 1749 */     String IntervaloFi = Day + Mess + Ano;
/* 1750 */     String IntervaloFf = Day2 + Mess2 + Ano2;

/* 1752 */     boolean rep = SendCmd("I2A" + IntervaloFi + IntervaloFf);
/* 1753 */     if (!rep)
    {
/* 1755 */       if (Integer.parseInt(Ano + Mess + Day) > Integer.parseInt(Ano2 + Mess2 + Day2)) {
/* 1756 */         this.Estado = "The date can not be larger than the final date";
      }
/* 1758 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    }
  }

  public void printZReport(int StarReportNumber, int EndReportNumber)
    throws PrinterExeption
  {
/* 1769 */     String IntervaloNi = String.valueOf(StarReportNumber);
/* 1770 */     while (IntervaloNi.length() < 6)
    {
/* 1772 */       IntervaloNi = "0" + IntervaloNi;
    }
/* 1774 */     String IntervaloNf = String.valueOf(EndReportNumber);
/* 1775 */     while (IntervaloNf.length() < 6)
    {
/* 1777 */       IntervaloNf = "0" + IntervaloNf;
    }

/* 1780 */     boolean rep = SendCmd("I3A" + IntervaloNi + IntervaloNf);
/* 1781 */     if (!rep)
    {
/* 1783 */       if (StarReportNumber > EndReportNumber) {
/* 1784 */         this.Estado = "The original number can not be greater than the final number";
      }
/* 1786 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    }
  }

  public void printXReport()
    throws PrinterExeption
  {
/* 1797 */     boolean rep = SendCmd("I0X");
/* 1798 */     if (!rep)
/* 1799 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public void printZReport()
    throws PrinterExeption
  {
/* 1808 */     boolean rep = SendCmd("I0Z");
/* 1809 */     if (!rep)
/* 1810 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public S1PrinterData getS1PrinterData()
    throws PrinterExeption
  {
    try
    {
/* 1821 */       int rep = SubirDataPCStatus("S1");

/* 1823 */       if (rep > 0)
      {
/* 1825 */         this.S1Estado = new S1PrinterData(this.datatrama);
/* 1826 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 1830 */         this.S1Estado = null;
/* 1831 */         this.Estado = "Sin repuesta";
/* 1832 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1835 */       return this.S1Estado;
    }
    catch (IOException ex) {
/* 1838 */       this.S1Estado = null;
/* 1839 */       this.Estado = ex.getMessage();
/* 1840 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1842 */       this.S1Estado = null;
/* 1843 */       this.Estado = ex.getMessage();
/* 1844 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1846 */       this.S1Estado = null;
/* 1847 */       this.Estado = ex.getMessage();
/* 1848 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public S2PrinterData getS2PrinterData()
    throws PrinterExeption
  {
    try
    {
/* 1860 */       int rep = SubirDataPCStatus("S2");

/* 1862 */       if (rep > 0)
      {
/* 1864 */         this.S2Estado = new S2PrinterData(this.datatrama);
/* 1865 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 1869 */         this.S2Estado = null;
/* 1870 */         this.Estado = "Sin repuesta";
/* 1871 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1874 */       return this.S2Estado;
    }
    catch (IOException ex) {
/* 1877 */       this.S2Estado = null;
/* 1878 */       this.Estado = ex.getMessage();
/* 1879 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1881 */       this.S2Estado = null;
/* 1882 */       this.Estado = ex.getMessage();
/* 1883 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1885 */       this.S2Estado = null;
/* 1886 */       this.Estado = ex.getMessage();
/* 1887 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public S3PrinterData getS3PrinterData()
    throws PrinterExeption
  {
    try
    {
/* 1898 */       int rep = SubirDataPCStatus("S3");

/* 1900 */       if (rep > 0)
      {
/* 1902 */         this.S3Estado = new S3PrinterData(this.datatrama);
/* 1903 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 1907 */         this.S3Estado = null;
/* 1908 */         this.Estado = "Sin repuesta";
/* 1909 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1912 */       return this.S3Estado;
    }
    catch (IOException ex) {
/* 1915 */       this.S3Estado = null;
/* 1916 */       this.Estado = ex.getMessage();
/* 1917 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1919 */       this.S3Estado = null;
/* 1920 */       this.Estado = ex.getMessage();
/* 1921 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1923 */       this.S3Estado = null;
/* 1924 */       this.Estado = ex.getMessage();
/* 1925 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public S4PrinterData getS4PrinterData()
    throws PrinterExeption
  {
    try
    {
/* 1936 */       int rep = SubirDataPCStatus("S4");

/* 1938 */       if (rep > 0)
      {
/* 1940 */         this.S4Estado = new S4PrinterData(this.datatrama);
/* 1941 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 1945 */         this.S4Estado = null;
/* 1946 */         this.Estado = "Sin repuesta";
/* 1947 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1950 */       return this.S4Estado;
    }
    catch (IOException ex) {
/* 1953 */       this.S4Estado = null;
/* 1954 */       this.Estado = ex.getMessage();
/* 1955 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1957 */       this.S4Estado = null;
/* 1958 */       this.Estado = ex.getMessage();
/* 1959 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1961 */       this.S4Estado = null;
/* 1962 */       this.Estado = ex.getMessage();
/* 1963 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public S5PrinterData getS5PrinterData()
    throws PrinterExeption
  {
    try
    {
/* 1974 */       int rep = SubirDataPCStatus("S5");

/* 1976 */       if (rep > 0)
      {
/* 1978 */         this.S5Estado = new S5PrinterData(this.datatrama);
/* 1979 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 1983 */         this.S5Estado = null;
/* 1984 */         this.Estado = "Sin repuesta";
/* 1985 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 1988 */       return this.S5Estado;
    }
    catch (IOException ex) {
/* 1991 */       this.S5Estado = null;
/* 1992 */       this.Estado = ex.getMessage();
/* 1993 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 1995 */       this.S5Estado = null;
/* 1996 */       this.Estado = ex.getMessage();
/* 1997 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 1999 */       this.S5Estado = null;
/* 2000 */       this.Estado = ex.getMessage();
/* 2001 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public S6PrinterData getS6PrinterData()
    throws PrinterExeption
  {
    try
    {
/* 2012 */       int rep = SubirDataPCStatus("S6");

/* 2014 */       if (rep > 0)
      {
/* 2016 */         this.S6Estado = new S6PrinterData(this.datatrama);
/* 2017 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 2021 */         this.S6Estado = null;
/* 2022 */         this.Estado = "Sin repuesta";
/* 2023 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 2026 */       return this.S6Estado;
    }
    catch (IOException ex) {
/* 2029 */       this.S6Estado = null;
/* 2030 */       this.Estado = ex.getMessage();
/* 2031 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 2033 */       this.S6Estado = null;
/* 2034 */       this.Estado = ex.getMessage();
/* 2035 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 2037 */       this.S6Estado = null;
/* 2038 */       this.Estado = ex.getMessage();
/* 2039 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }

  public S7PrinterData getS7PrinterData()
    throws PrinterExeption
  {
    try
    {
/* 2050 */       int rep = SubirDataPCStatus("S7");

/* 2052 */       if (rep > 0)
      {
/* 2054 */         this.S7Estado = new S7PrinterData(this.datatrama);
/* 2055 */         this.Estado = " Status: 00  Error: 00";
      }
      else
      {
/* 2059 */         this.S7Estado = null;
/* 2060 */         this.Estado = "Sin repuesta";
/* 2061 */         throw new PrinterExeption(this.Estado, getPrinterStatus());
      }

/* 2064 */       return this.S7Estado;
    }
    catch (IOException ex) {
/* 2067 */       this.S7Estado = null;
/* 2068 */       this.Estado = ex.getMessage();
/* 2069 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (InterruptedException ex) {
/* 2071 */       this.S7Estado = null;
/* 2072 */       this.Estado = ex.getMessage();
/* 2073 */       throw new PrinterExeption(this.Estado, getPrinterStatus());
    } catch (NullPointerException ex) {
/* 2075 */       this.S7Estado = null;
/* 2076 */       this.Estado = ex.getMessage();
/* 2077 */     }throw new PrinterExeption(this.Estado, getPrinterStatus());
  }
}

/* Location:           C:\Users\javaOne\Documents\TfhkaJava.jar
 * Qualified Name:     tfhka.Tfhka
 * JD-Core Version:    0.6.2
 */